#include "CPlatform.h"
#include "CRender.h"
#include "CAnimationEngine.h"

CPlatform::CPlatform()
{
	m_fInnerLimit = 0.0f;
	m_fOuterLimit = 0.0f;
	m_fThetaFirst = 0.0f;
	m_fThetaSecond = 0.0f;

	m_nDirection = rand()%2;

	m_unType = NOODLE;
	m_pTexHandle = NULL;
	//m_shapeObject = NULL;
	m_bVisible = false;
	m_bCollidable = true;
}

CPlatform::~CPlatform()
{

}

void CPlatform::Update(float fElapsed)
{
	//MovePlatform(fElapsed);
}

void CPlatform::Render()
{
	if(m_bVisible)
		CRender::GetInstance()->DrawTex(m_pTexHandle, &m_shapeObject, Vec2(m_Pos.x, m_Pos.y));
}

void CPlatform::MovePlatform(float fElapsed)
{
	for(int i = 0; i < m_shapeObject.m_numberVerts; ++i)
	{
		Vec3 newVert(m_shapeObject.m_pVertexData[i].x, m_shapeObject.m_pVertexData[i].y, 0.0f);

		if(m_nDirection)
		{
			newVert = newVert * Mat4::GetRotateZ(0.2f) * fElapsed;
		}
		else
		{
			newVert = newVert * Mat4::GetRotateZ(-0.2f) * fElapsed;
		}

		m_shapeObject.m_pVertexData[i] = Vec2(newVert.x, newVert.y);
	}
}